﻿using System.Collections.Generic;
using Gola.VN.Scb.Web.Bll;
using Gola.VN.Scb.Web.Common.Entities;
using Gola.VN.Scb.Web.Common.Models;

namespace Gola.VN.Scb.Web.Presentation.Models
{
    internal class SearchServiceNew : BaseService
    {
        public SearchServiceNew(MainBiz mainBiz)
            : base(mainBiz)
        {
        }

        internal List<UISearchResultModels> DoSearch(string searchText, int maxResults = 10)
        {
            var package = new BizPackage();
            
            package.Model = ModelType.Search;
            package.Event = BizEvent.DoSearch;
            package.MultiInput = new List<object>(2);
            package.MultiInput[0] = searchText;
            package.MultiInput[1] = maxResults;
            _mainBiz.Execute(package);

            return package.Output as List<UISearchResultModels>;
        }
    }

    internal class SearchHistoryServiceNew : BaseService
    {
        public SearchHistoryServiceNew(MainBiz mainBiz)
            : base(mainBiz)
        {
        }

        internal List<SearchHistoryEntity> GetSearchHistories()
        {
            // 1. Get Search Histories
            var package = new BizPackage();
            package.Model = ModelType.Search;
            package.Event = BizEvent.GetSearchHistories;
            _mainBiz.Execute(package);
            return package.Output as List<SearchHistoryEntity>;
        }

        internal void UpdateSearchHistory(SearchHistoryEntity searchHistory)
        {
            var package = new BizPackage();
            package.Model = ModelType.Search;
            package.Event = BizEvent.UpdateSearchHistory;
            package.Input = searchHistory;
            _mainBiz.Execute(package);
        }
    }
}